package com.aspose.cells;

class zbsg {
   private static final com.aspose.cells.b.c.a.za a = new com.aspose.cells.b.c.a.za(new String[]{"DATA", "ALL", "HEADERS", "DATA2", "DATAHEADERS", "TOTALS", "DATATOTALS", "CURRENT", "THIS ROW"});

   static String a(WorksheetCollection var0, Cell var1, byte[] var2, int var3, int var4, int var5, int var6) {
      int var7 = com.aspose.cells.b.a.zc.e(var2, var3 + 2) & '\uffff';
      int var8 = com.aspose.cells.b.a.zc.e(var2, var3 + 4);
      int var9 = com.aspose.cells.b.a.zc.a(var2, var3 + 6);
      int var10 = var0.q().c(var7);
      int var11 = var0.q().d(var7);
      if (var10 != var0.u()) {
         var3 += 14;
         return "#REF!";
      } else if (var11 >= 0 && var11 <= var0.getCount()) {
         ListObject var12 = var0.get(var11).getListObjects().a(var9);
         if (var12 != null && (var2[var3 + 5] & 255 & 48) == 0) {
            int var13 = com.aspose.cells.b.a.zc.e(var2, var3 + 10) & '\uffff';
            int var14 = com.aspose.cells.b.a.zc.e(var2, var3 + 12) & '\uffff';
            if (var13 >= var12.getListColumns().getCount()) {
               var3 += 14;
               return "#REF!";
            } else {
               if (var14 >= var12.getListColumns().getCount()) {
                  var14 = var13;
               }

               int var15 = var8 & '\uffff' & 3;
               var3 += 14;
               StringBuilder var16 = new StringBuilder();
               boolean var17 = true;
               boolean var18 = var1 != null && var1.d.h().getIndex() == var11;
               if (!var18 || var4 < var12.getStartRow() || var4 > var12.getEndRow() || var5 < var12.getStartColumn() || var5 > var12.getEndColumn()) {
                  var17 = false;
               }

               String var19 = null;
               switch((var8 & '\uffff') >> 2 & 31) {
               case 1:
                  var19 = "#All";
                  break;
               case 2:
                  var19 = "#Headers";
               case 3:
               case 5:
               case 7:
               case 9:
               case 10:
               case 11:
               case 13:
               case 14:
               case 15:
               default:
                  break;
               case 4:
                  var19 = "#Data";
                  break;
               case 6:
                  var19 = "#DataHeaders";
                  break;
               case 8:
                  var19 = "#Totals";
                  break;
               case 12:
                  var19 = "#DataTotals";
                  break;
               case 16:
                  var19 = "#This Row";
                  if (var6 != 1) {
                     if (!var17 || var15 == 0 || var13 != var14) {
                        var16.append(var12.getDisplayName());
                     }

                     var16.append('[');
                     var16.append('@');
                     if (var15 != 0) {
                        if (var13 == var14) {
                           boolean var20 = zakq.b(var12.getListColumns().get(var13).getName());
                           if (var20) {
                              var16.append('[');
                           }

                           var16.append(zyn.a(var12.getListColumns().get(var13).getName()));
                           if (var20) {
                              var16.append(']');
                           }
                        } else {
                           var16.append('[');
                           var16.append(zyn.a(var12.getListColumns().get(var13).getName()));
                           var16.append(']');
                           var16.append(':');
                           var16.append('[');
                           var16.append(zyn.a(var12.getListColumns().get(var14).getName()));
                           var16.append(']');
                        }
                     }

                     var16.append(']');
                     return com.aspose.cells.b.a.zr.a(var16);
                  }
               }

               if (var19 != null) {
                  if (var15 == 0) {
                     var16.append(var12.getDisplayName());
                     var16.append('[');
                     var16.append(var19);
                     var16.append("]");
                     return com.aspose.cells.b.a.zr.a(var16);
                  } else {
                     var16.append(var12.getDisplayName());
                     var16.append('[');
                     var16.append('[');
                     var16.append(var19);
                     var16.append("],[");
                     var16.append(zyn.a(var12.getListColumns().get(var13).getName()));
                     var16.append("]");
                     if (var14 != var13) {
                        var16.append(":[");
                        var16.append(zyn.a(var12.getListColumns().get(var14).getName()));
                        var16.append("]");
                     }

                     var16.append("]");
                     return com.aspose.cells.b.a.zr.a(var16);
                  }
               } else if (var15 == 0) {
                  var16.append(var12.getDisplayName());
                  if (var6 == 1) {
                     var16.append("[]");
                  }

                  return com.aspose.cells.b.a.zr.a(var16);
               } else {
                  if (!var17 || var13 != var14) {
                     var16.append(var12.getDisplayName());
                  }

                  var16.append('[');
                  if (var13 == var14) {
                     var16.append(a(var12.getListColumns().get(var13).getName()));
                  } else {
                     var16.append('[');
                     var16.append(zyn.a(var12.getListColumns().get(var13).getName()));
                     var16.append("]:[");
                     var16.append(zyn.a(var12.getListColumns().get(var14).getName()));
                     var16.append(']');
                  }

                  var16.append(']');
                  return com.aspose.cells.b.a.zr.a(var16);
               }
            }
         } else {
            var3 += 14;
            return "#REF!";
         }
      } else {
         var3 += 14;
         return "#REF!";
      }
   }

   static String a(String var0) {
      return com.aspose.cells.b.a.zv.a(com.aspose.cells.b.a.zv.a(var0, "'", "''"), "#", "'#");
   }

   static Range a(WorksheetCollection var0, int var1, int var2, int var3, String var4, boolean var5) {
      int[] var6 = b(var0, var1, var2, var3, var4, var5);
      if (var6 == null) {
         return null;
      } else {
         int var7 = var6[0];
         int var8 = var6[1];
         int var9 = var6[2];
         int var10 = var6[3];
         int var11 = var6[4];
         var1 = var0.q().d(var7);
         return var1 >= 0 && var1 < var0.getCount() ? new Range(var8, var9, var10 - var8 + 1, var11 - var9 + 1, var0.get(var1).getCells()) : null;
      }
   }

   static int[] b(WorksheetCollection var0, int var1, int var2, int var3, String var4, boolean var5) {
      boolean var6 = false;
      boolean[] var7 = new boolean[]{var6};
      byte[] var8 = a(var0, var1, var2, var3, var4, 32, var7);
      var6 = var7[0];
      return var6 ? null : a(var0, var8, 0, var2, var3, var5);
   }

   static int[] a(WorksheetCollection var0, byte[] var1, int var2, int var3, int var4, boolean var5) {
      int var6 = com.aspose.cells.b.a.zc.e(var1, var2 + 2) & '\uffff';
      int var7 = com.aspose.cells.b.a.zc.e(var1, var2 + 4) & '\uffff';
      int var8 = com.aspose.cells.b.a.zc.a(var1, var2 + 6);
      int var9 = var0.q().c(var6);
      int var10 = var0.q().d(var6);
      if (var9 != var0.u()) {
         return null;
      } else if (var10 >= 0 && var10 <= var0.getCount()) {
         ListObject var11 = var0.get(var10).getListObjects().a(var8);
         if (var11 != null && (var1[var2 + 5] & 255 & 48) == 0) {
            int var12 = com.aspose.cells.b.a.zc.e(var1, var2 + 10) & '\uffff';
            int var13 = com.aspose.cells.b.a.zc.e(var1, var2 + 12) & '\uffff';
            if (var12 >= var11.getListColumns().getCount()) {
               return null;
            } else {
               var12 += var11.getStartColumn();
               var13 += var11.getStartColumn();
               int var14 = var11.getStartRow();
               int var15 = var11.getEndRow();
               int var16 = var7 & 3;
               switch(var7 >> 2 & 31) {
               case 1:
                  if (var16 == 0) {
                     var12 = var11.getStartColumn();
                     var13 = var11.getEndColumn();
                  }
                  break;
               case 2:
                  var14 = var15 = var11.getStartRow();
                  if (var16 == 0) {
                     var12 = var11.getStartColumn();
                     var13 = var11.getEndColumn();
                  }
                  break;
               case 8:
                  if (!var11.j()) {
                     return null;
                  }

                  var14 = var15 = var11.getEndRow();
                  break;
               case 16:
                  var15 = var3;
                  var14 = var3;
                  break;
               default:
                  if (var11.getShowHeaderRow() && !var5) {
                     ++var14;
                  }

                  if (var11.getShowTotals()) {
                     --var15;
                  }

                  if (var16 == 0) {
                     var12 = var11.getStartColumn();
                     var13 = var11.getEndColumn();
                  }
               }

               int[] var17 = new int[]{var6, var14, var12, var15, var13};
               return var17;
            }
         } else {
            return null;
         }
      } else {
         return null;
      }
   }

   static byte[] a(WorksheetCollection var0, int var1, String var2, int var3) {
      ListObject var4 = (ListObject)var0.d.get(var2.toUpperCase());
      if (var4 == null) {
         return null;
      } else {
         int var5 = var4.a();
         if (var5 == -1) {
            return null;
         } else {
            byte[] var6 = new byte[14];
            var6[0] = 24;
            var6[1] = 25;
            boolean var7 = false;
            int var9 = var0.q().b(var0.u(), var1);
            System.arraycopy(com.aspose.cells.b.a.zc.a(var9), 0, var6, 2, 2);
            byte var8 = 0;
            int var10;
            if (var3 == 96) {
               var10 = var8 | 2048;
            } else {
               var10 = var8 | 1024;
            }

            System.arraycopy(com.aspose.cells.b.a.zc.a((long)var5), 0, var6, 6, 4);
            System.arraycopy(com.aspose.cells.b.a.zc.a(var10), 0, var6, 4, 2);
            return var6;
         }
      }
   }

   static ListObject a(WorksheetCollection var0, String var1) {
      for(int var2 = 0; var2 < var0.getCount(); ++var2) {
         ListObjectCollection var3 = var0.get(var2).getListObjects();

         for(int var4 = 0; var4 < var3.getCount(); ++var4) {
            ListObject var5 = var3.get(var4);
            if (com.aspose.cells.b.a.zv.a(var5.getDisplayName(), var1, true) == 0) {
               return var5;
            }
         }
      }

      return null;
   }

   static byte[] a(WorksheetCollection var0, int var1, int var2, int var3, String var4, int var5, boolean[] var6) {
      byte[] var7 = new byte[14];
      var7[0] = 24;
      var7[1] = 25;
      int var8 = var4.lastIndexOf(33);
      boolean var9 = false;
      boolean var10 = false;
      String var11;
      int var14;
      int var25;
      if (var8 != -1) {
         var10 = true;
         var11 = var4.substring(0, 0 + var8);
         var4 = var4.substring(var8 + 1).trim();
         var11 = zyn.b(var11);
         int[] var15 = zyn.a(var0, var11);
         var25 = var15[0];
         int var12 = var15[1];
         int var13 = var15[2];
         var14 = var15[3];
         var1 = var13;
      } else {
         var25 = var0.q().b(var0.u(), var1);
      }

      System.arraycopy(com.aspose.cells.b.a.zc.a(var25), 0, var7, 2, 2);
      var11 = null;
      if (var4.charAt(0) != '[') {
         var8 = var4.indexOf(91);
         if (var8 == -1) {
            var11 = var4;
            var4 = null;
         } else {
            var11 = var4.substring(0, 0 + var8);
            var4 = var4.substring(var8).trim();
            var4 = com.aspose.cells.b.a.zv.a(com.aspose.cells.b.a.zv.a(var4, "''", "'"), "'#", "#");
         }
      }

      ListObjectCollection var26 = null;
      ListObject var27 = null;
      var14 = -1;
      int var17;
      int var28;
      if (var11 == null) {
         var26 = var0.get(var1).getListObjects();

         for(var28 = 0; var28 < var26.getCount(); ++var28) {
            ListObject var16 = var26.get(var28);
            if (var16.getStartRow() <= var2 && var16.getStartColumn() <= var3 && var16.getEndRow() >= var2 && var16.getEndColumn() >= var3) {
               var27 = var16;
               var14 = var16.a();
               break;
            }
         }
      } else {
         for(var28 = 0; var28 < var0.getCount(); ++var28) {
            var26 = var0.get(var28).getListObjects();
            boolean var29 = false;

            for(var17 = 0; var17 < var26.getCount(); ++var17) {
               ListObject var18 = var26.get(var17);
               if (com.aspose.cells.b.a.zv.a(var18.getDisplayName(), var11, true) == 0) {
                  var27 = var18;
                  var14 = var18.a();
                  if (!var10 && var1 != var28) {
                     var25 = var0.q().b(var0.u(), var28);
                     System.arraycopy(com.aspose.cells.b.a.zc.a(var25), 0, var7, 2, 2);
                  }

                  var29 = true;
                  break;
               }
            }

            if (var29) {
               break;
            }
         }
      }

      byte var30 = 0;
      if (var5 == 96) {
         var28 = var30 | 2048;
      } else {
         var28 = var30 | 1024;
      }

      var6[0] = false;
      if (var27 == null) {
         var7[5] = 48;
         var7[6] = -1;
         var7[7] = -1;
         var7[8] = -1;
         var7[9] = -1;
         var6[0] = true;
         return var7;
      } else {
         System.arraycopy(com.aspose.cells.b.a.zc.a((long)var14), 0, var7, 6, 4);
         if (var4 == null) {
            System.arraycopy(com.aspose.cells.b.a.zc.a(var28), 0, var7, 4, 2);
            return var7;
         } else {
            int var19;
            int var34;
            if (var4.indexOf("],") != -1) {
               var8 = var4.indexOf("],");
               String var31 = var4.substring(3, 3 + (var8 - 3)).toUpperCase();
               String var33 = var4.substring(var8 + 2, var8 + 2 + (var4.length() - (var8 + 3))).toUpperCase();
               var34 = -1;
               var19 = -1;
               var28 |= 1;
               byte var20 = 0;
               switch(a.a(var31)) {
               case 0:
                  var20 = 4;
                  break;
               case 1:
                  var20 = 1;
                  break;
               case 2:
                  var20 = 2;
                  break;
               case 3:
                  var20 = 4;
                  break;
               case 4:
                  var20 = 6;
                  break;
               case 5:
                  var20 = 8;
                  break;
               case 6:
                  var20 = 12;
                  break;
               case 7:
               case 8:
                  var20 = 16;
               }

               var8 = var33.indexOf("]:[");
               if (var8 != -1) {
                  String var37 = var33.substring(1, 1 + (var8 - 1));
                  String var38 = var33.substring(var8 + 3, var8 + 3 + (var33.length() - (var8 + 4)));

                  for(int var23 = 0; var23 < var27.getListColumns().getCount(); ++var23) {
                     ListColumn var24 = var27.getListColumns().get(var23);
                     if (com.aspose.cells.b.a.zv.b(var24.getName().toUpperCase(), var37)) {
                        var34 = var23;
                     } else if (com.aspose.cells.b.a.zv.b(var24.getName().toUpperCase(), var38)) {
                        var19 = var23;
                     }
                  }
               } else {
                  var33 = var33.substring(1, 1 + (var33.length() - 2));
                  var33 = com.aspose.cells.b.a.zv.a(var33, "''", "'");

                  for(int var21 = 0; var21 < var27.getListColumns().getCount(); ++var21) {
                     ListColumn var22 = var27.getListColumns().get(var21);
                     if (com.aspose.cells.b.a.zv.b(var22.getName().toUpperCase(), var33)) {
                        var19 = var21;
                        var34 = var21;
                        break;
                     }
                  }
               }

               if (var34 != -1 && var19 != -1) {
                  var28 |= var20 << 2;
                  System.arraycopy(com.aspose.cells.b.a.zc.a(var28), 0, var7, 4, 2);
                  System.arraycopy(com.aspose.cells.b.a.zc.a(var34), 0, var7, 10, 2);
                  System.arraycopy(com.aspose.cells.b.a.zc.a(var19), 0, var7, 12, 2);
                  return var7;
               }
            } else {
               var4 = var4.substring(1, 1 + (var4.length() - 2)).trim().toUpperCase();
               int var32 = -1;
               var17 = -1;
               if (var4 != null && !"".equals(var4)) {
                  if ("[#ALL]".equals(var4)) {
                     var4 = var4.substring(1, 1 + (var4.length() - 2)).trim();
                  }

                  if (var4.length() > 0 && var4.charAt(0) == '@') {
                     var4 = var4.substring(1);
                     var28 |= 64;
                     if (var4.length() > 0 && var4.charAt(0) == '[') {
                        var4 = var4.substring(1, 1 + (var4.length() - 2));
                     }
                  }

                  if (var4.charAt(0) == '#' && var4.length() > 1) {
                     byte var36 = 0;
                     switch(a.a(var4.substring(1))) {
                     case 0:
                        var36 = 4;
                        break;
                     case 1:
                        var36 = 1;
                        break;
                     case 2:
                        var36 = 2;
                        break;
                     case 3:
                        var36 = 4;
                        break;
                     case 4:
                        var36 = 6;
                        break;
                     case 5:
                        var36 = 8;
                        break;
                     case 6:
                        var36 = 12;
                        break;
                     case 7:
                     case 8:
                        var36 = 16;
                     }

                     var28 |= var36 << 2;
                     var17 = 0;
                     var32 = 0;
                  } else {
                     var8 = var4.indexOf(":");
                     if (var8 == -1) {
                        var28 |= 1;

                        for(var34 = 0; var34 < var27.getListColumns().getCount(); ++var34) {
                           ListColumn var39 = var27.getListColumns().get(var34);
                           if (com.aspose.cells.b.a.zv.b(var39.getName().toUpperCase(), var4)) {
                              var17 = var34;
                              var32 = var34;
                              break;
                           }
                        }
                     } else {
                        var28 |= 2;
                        String[] var35 = com.aspose.cells.b.a.zv.d(var4, ':');

                        for(var19 = 0; var19 < var35.length; ++var19) {
                           if (var35[var19].charAt(0) == '[') {
                              var35[var19] = var35[var19].substring(1, 1 + (var35[var19].length() - 2));
                           }
                        }

                        ListColumn var40;
                        for(var19 = 0; var19 < var27.getListColumns().getCount(); ++var19) {
                           var40 = var27.getListColumns().get(var19);
                           if (com.aspose.cells.b.a.zv.b(var40.getName().toUpperCase(), var35[0])) {
                              var32 = var19;
                              break;
                           }
                        }

                        for(var19 = 0; var19 < var27.getListColumns().getCount(); ++var19) {
                           var40 = var27.getListColumns().get(var19);
                           if (com.aspose.cells.b.a.zv.b(var40.getName().toUpperCase(), var35[1])) {
                              var17 = var19;
                              break;
                           }
                        }
                     }
                  }
               } else {
                  var17 = 0;
                  var32 = 0;
               }

               if (var32 != -1 && var17 != -1) {
                  System.arraycopy(com.aspose.cells.b.a.zc.a(var28), 0, var7, 4, 2);
                  System.arraycopy(com.aspose.cells.b.a.zc.a(var32), 0, var7, 10, 2);
                  System.arraycopy(com.aspose.cells.b.a.zc.a(var17), 0, var7, 12, 2);
                  return var7;
               }
            }

            var7[5] = 48;
            var7[6] = -1;
            var7[7] = -1;
            var7[8] = -1;
            var7[9] = -1;
            return var7;
         }
      }
   }
}
